package com.smart.controller;

import com.smart.pojo.ReimbursementBill;
import com.smart.pojo.ResultBean;
import com.smart.req.ReimbursementCompleteData;
import com.smart.service.ReimbursementProcessService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("reimbursementProcess")
public class ReimbursementProcessController {
    @Autowired
    private ReimbursementProcessService reimbursementProcessService;

    /**
     * 开启报销流程实例
     */
    @PostMapping("startProcess")
    public ResultBean startReimbursementProcess(@RequestBody ReimbursementBill reimbursementBill){
        System.out.println("报销申请详情：" + reimbursementBill);
        boolean rs = reimbursementProcessService.startReimbursementProcess(reimbursementBill);
        return rs ? ResultBean.success() : ResultBean.error();
    }

    /**
     * 报销单流程推进
     */
    @PostMapping("complete")
    public ResultBean complete(@RequestBody ReimbursementCompleteData reimbursementCompleteData){
        System.out.println("报销流程推进信息：" + reimbursementCompleteData);
        reimbursementProcessService.complete(reimbursementCompleteData);
        return ResultBean.success();
    }
}
